<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">公司列表</ui:define>
    <ui:define name="content">
        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton  process="@this" id="add" icon="fa fa-plus" value="新增" action="#{companyListBean.onAdd}">
                            <f:setPropertyActionListener
                                    value="/views/settlement/online-config/company-list.xhtml"
                                    target="#{currentUserBean.back}"/>
                        </p:commandButton>
                        <p:commandButton update="@form" id="search" value="查询" icon="fa fa-search"/>
                        <p:commandButton value="重置" icon="fa fa-refresh" process="@this" update="@form"
                                         actionListener="#{companyListBean.onReset}"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-g ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12 ">
                    <div class="ui-g-12 card">
                        <h1>查询条件</h1>
                        <div class="ui-g-1">
                            <p:outputLabel value="创建时间"/>
                        </div>
                        <div class="ui-g-3">
                            <p:calendar value="#{companyListBean.$.startTime}"
                                        id="recordStartTime" styleClass="autoWidthCalendar"
                                        locale="#{constants:get('LOCALE')}"
                                        timeZone="#{constants:get('TIME_ZONE')}"
                                        pattern="#{constants:get('DATE_FORMAT')}"/>
                            <span>—</span>
                            <p:calendar value="#{companyListBean.$.endTime}"
                                        id="recordEndTime" styleClass="autoWidthCalendar"
                                        locale="#{constants:get('LOCALE')}"
                                        timeZone="#{constants:get('TIME_ZONE')}"
                                        pattern="#{constants:get('DATE_FORMAT')}"/>
                        </div>

                        <div class="ui-g-1">
                            <p:outputLabel value="公司名称"/>
                        </div>
                        <div class="ui-g-3">
                            <p:inputText value="#{companyListBean.$.companyName}"/>
                        </div>
                        <div class="ui-g-1">
                            <p:outputLabel value="负责人"/>
                        </div>
                        <div class="ui-g-3">
                            <p:selectOneMenu id="principal" value="#{companyListBean.$.principal}" filter="true"
                                             filterMatchMode="contains">
                                <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                              noSelectionOption="true"/>
                                <f:selectItems value="#{companyListBean.principalList}"
                                               var="principal"
                                               itemLabel="#{principal.name}" itemValue="#{principal.account}"/>
                            </p:selectOneMenu>
                        </div>
                    </div>
                </div>
                <div class="ui-g-12">
                    <div class="ui-g-12 card">
                        <h1>查询结果</h1>
                        <p:dataTable id="userDataTable"
                                     style="width: 100%;text-align: center"
                                     var="company"
                                     value="#{companyListBean.lazyDataModel}"
                                     rows="#{constants:get('ROWS')}"
                                     lazy="true"
                                     paginator="true"
                                     paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                     rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                     emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                     scrollable="true"
                                     scrollWidth="97%"
                                     reflow="true"
                                     selection=""
                                     resizableColumns="true">
                            <p:column headerText="操作">
                                <p:splitButton icon="fa fa-eye"
                                               process="@this" action="#{companyListBean.onSee(company.id)}">
                                    <f:setPropertyActionListener
                                            value="/views/settlement/online-config/company-list.xhtml"
                                            target="#{currentUserBean.back}"/>
                                </p:splitButton>
                            </p:column>
                            <p:column headerText="公司名称">
                                <h:outputText value="#{company.companyName}"/>
                            </p:column>
                            <p:column headerText="产品名称">
                                <h:outputText value="#{company.productName}"/>
                            </p:column>
                            <p:column headerText="创建人">
                                <h:outputText value="#{company.creator}"/>
                            </p:column>
                            <p:column headerText="创建时间">
                                <h:outputText value="#{company.createTime}">
                                    <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="负责人">
                                <h:outputText value="#{company.principal}"/>
                            </p:column>
                            <p:column headerText="审核状态">
                                <h:outputText value="#{companyListBean.getAuditStatus(company.auditStatus)}"/>
                            </p:column>
                        </p:dataTable>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
